<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>1.canvas绘制圆形</title>
    <style>
      canvas {
        border: 1px solid #000;
      }
    </style>
  </head>
  <body>
    <canvas width="800" height="600"></canvas>
    <script>
      const canvas = document.querySelector('canvas');
      const ctx = canvas.getContext('2d');
      ctx.beginPath();
      // 调用方法绘制圆形
      ctx.arc(200, 200, 100, 0, Math.PI * 2, true);
      // ctx.fillStyle = 'blue';
      // ctx.fill()
      ctx.stroke();
      ctx.closePath();

      ctx.beginPath();
      ctx.arc(300, 300, 100, 0, Math.PI * 2, true);
      ctx.stroke();
      ctx.closePath();

      // 绘制半圆
      ctx.beginPath();
      ctx.arc(500, 200, 100, 0, Math.PI, true);
      ctx.stroke();
      ctx.closePath();

      // 绘制四分之一圆
      ctx.beginPath();
      ctx.arc(500, 400, 100, Math.PI * 0.5, Math.PI, false);
      ctx.stroke();
      ctx.closePath();

      ctx.font = '50px 楷书';
      ctx.fillText('绘制圆形及部分', 50, 50, '200');
    </script>
  </body>
</html>
